package com.bbs.toutiao.service.admin.impl;


import com.bbs.toutiao.aspect.SysLog;
import com.bbs.toutiao.entity.NotificationsEntity;
import com.bbs.toutiao.mapper.admin.NotAdminMapper;
import com.bbs.toutiao.mapper.clinet.ClientUserMapper;
import com.bbs.toutiao.service.admin.NotificationService;
import com.bbs.toutiao.vo.article.ArticlePageRequestVo;
import com.bbs.toutiao.vo.client.AddNotificationVo;
import com.bbs.toutiao.vo.comm.PageVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 描述: 举报信息服务层
 * 作者： zhangBin
 * 时间： 2023/9/28 23:43
 * 版本： 1.0
 */

@Slf4j
@Service
public class NotServiceImpl implements NotificationService {

    @Resource
    NotAdminMapper adminMapper;

    @Resource
    ClientUserMapper clientUserMapper;


    //动态分页获取举报信息
    @Override
    public PageVo<NotificationsEntity> getAllNot(ArticlePageRequestVo requestVo) {
        List<NotificationsEntity> entities = adminMapper.getAllNotifications(requestVo);
        int count = adminMapper.getCountByNotifications(requestVo);
        PageVo<NotificationsEntity> pageVo = new PageVo<>();
        pageVo.setPageList(entities);
        pageVo.setTotal((long)count);
        return pageVo;
    }

    /**
     * 批量动态更新
     * @param mapList
     * @return
     */
    @SysLog("管理员操作了批量处理消息")
    @Transactional
    @Override
    public int updateStatus(List<Map<String, Integer>> mapList) {
        return adminMapper.batchUpdateStatus(mapList);
    }

    /**
     * 新增举报信息
     * @param addNotificationVo
     * @return
     */
    @Override
    public int addNot(AddNotificationVo addNotificationVo) {
        return clientUserMapper.insertNotification(addNotificationVo);
    }
}
